package cn.tedu.csmall.stock.webapi.service;

import cn.tedu.csmall.commons.pojo.stock.dto.StockReduceCountDTO;
import cn.tedu.csmall.stock.service.IStockService;
import cn.tedu.csmall.stock.webapi.mapper.StockMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//@DubboService注解表示当前业务逻辑层实现类中的所有方法均会注册到nacos
// 成为Dubbo可以发现的业务逻辑层的方法
@DubboService
@Service
@Slf4j
public class StockService implements IStockService {

    @Autowired
    private StockMapper mapper;

    @Override
    public void reduceCommodityCount(StockReduceCountDTO stockReduceCountDTO) {
        mapper.updateStockByCommodityCount(
                stockReduceCountDTO.getReduceCount(),//第一个采纳数商品编号
                stockReduceCountDTO.getCommodityCode());//第二个参数是减少的库存数
        log.info("减少库存完成");
    }
}
